<template>
  <el-container>
    <el-header class="sa-header">
      <div class="sa-title-top">
        <div class="title-text">账户流水</div>
      </div>
      <div class="title-money">
        <div class="money-body">
            <div class="money-text">
                <span>133 </span>单
            </div>
            <div class="money-text">
                总订单数
            </div>
        </div>
        <div class="money-body">
            <div class="money-text">
                <span>7589 </span>元
            </div>
            <div class="money-text">
                总收入
            </div>
        </div>
        <div class="money-body">
            <div class="money-text">
                <span>334 </span>元
            </div>
            <div class="money-text">
                待结算
            </div>
        </div>
        <div class="money-body">
            <div class="money-text">
                <span>7194 </span>元
            </div>
            <div class="money-text">
                可结算
            </div>
        </div>
        <div class="money-body">
            <div class="money-text">
                <span>61 </span>元
            </div>
            <div class="money-text">
                退款
            </div>
        </div>
        <div class="money-body">
            <div class="money-text">
                <span>1138.35 </span>元
            </div>
            <div class="money-text">
                分账金额
            </div>
        </div>
        <div class="money-body">
            <div class="money-text">
                <span>0 </span>元
            </div>
            <div class="money-text">
                已提现到余额
            </div>
        </div>
      </div>
      <div class="sa-title sa-flex sa-row-between">
        <div class="label sa-flex">
          <span class="left"></span>
          <search-condition
            :conditionLabel="filterParams.conditionLabel"
            @deleteFilter="deleteFilter"
          ></search-condition>
        </div>
        <div>
          <el-button
            v-auth="'seller.admin.application.list'"
            class="sa-button-refresh"
            icon="RefreshRight"
            @click="getData()"
          ></el-button>
          <el-button class="sa-button-refresh" icon="Search" @click="openFilter"></el-button>
        </div>
      </div>
    </el-header>
    <el-main class="sa-p-0" v-loading="table.loading">
      <el-table class="sa-table" height="100%" :data="table.data" stripe>
        <template #empty>
          <sa-empty />
        </template>
        <el-table-column sortable="custom" prop="id" label="ID" min-width="80" />
        <el-table-column prop="merchant_name" label="下单用户" min-width="150" align="center" />
        <el-table-column prop="skfs" label="收款方式" min-width="150" align="center" />
        <el-table-column prop="create_time" label="结算时间" min-width="150" align="center" />
        <el-table-column prop="status" label="支付状态" min-width="120" align="center" />
        <el-table-column prop="money1" label="收款金额" min-width="120" align="center" />
        <el-table-column prop="money2" label="分账金额" min-width="120" align="center" />
        <el-table-column fixed="right" label="操作" min-width="150">
          <template #default="scope">
            <el-button
              v-auth="'seller.admin.application.details'"
              class="delete-btn"
              type="text"
              @click="see(scope.row)"
            >删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-main>
    <sa-view-bar>
      <template #right>
        <sa-pagination :pageData="pageData" @updateFn="getData" />
      </template>
    </sa-view-bar>
  </el-container>
</template>
<script>
  export default {
    name: 'seller.admin.info',
  };
</script>

<script setup>
  import { onMounted, reactive } from 'vue';
  import { api } from '../info.service';
  import { usePagination, useModal } from '@/sheep/hooks';
  import { useSearch } from '@/sheep/components/sa-table/sa-search/useSearch';
  import { composeFilter } from '@/sheep/utils';
  import { useRoute } from 'vue-router';
  import _ from 'lodash';

  const statusList = [
    { name: '生效中', type: 'all' },
    { name: '审核中', type: '0' },
    { name: '审核不通过', type: '1' },
    { name: '已撤回', type: '2' }];
    const statusList2 = [
    { name: '入驻', type: '1' },
    { name: '进件', type: '2' },
   ];

  const route = useRoute();
  const emit = defineEmits(['modalCallBack']);

  const filterParams = reactive({
    tools: {
      create_time: {
        type: 'tdatetimerange',
        label: '时间',
        field: 'create_time',
        value: route.query.create_time || [],
        create_time: route.query.create_time || [],
      },
    },
    data: {
      type:'1',
      audit: 'all',
      serve: '',
      user: { field: 'user.nickname', value: '' },
      create_time: route.query.create_time || [],
    },
    conditionLabel: {},
  });

  const { openFilter, deleteFilter } = useSearch({ filterParams, getData });

  const table = reactive({
    loading: false,
    data: [],
  });

  const { pageData } = usePagination();

  const calcStatus = (row) => {
    if (row.status === 0) return '待审核';
    if (row.status === 1) return '已审核';
    if (row.status === 2) return '已驳回';
  };

  async function getData(page) {
    // table.loading = true;
    // if (page) pageData.page = page;
    // let tempSearch = _.cloneDeep(filterParams.data);
    // let search = composeFilter(tempSearch, {
    //   'user.nickname': 'like',
    //   'user.id': 'like',
    //   'user.merchant_name': 'like',
    //   create_time: 'range',
    //   serve: 'like',
    // });

    // if (!_.isEmpty(search)) {
    //   if (_.includes(search.search, 'audit')) {
    //     search.search = _.replace(search.search, /audit/, 'status');
    //   }
    // }
    // const { error, data } = await api.list({
    //   page: pageData.page,
    //   list_rows: pageData.list_rows,
    //   ...search,
    // });
    // if (error === 0) {
    //   table.data = data.data;
    //   pageData.page = data.current_page;
    //   pageData.list_rows = data.per_page;
    //   pageData.total = data.total;
    // }
    // table.loading = false;
    table.loading = true;
    table.data = [
      {
        id:'1023',
        merchant_name:'来自****吴',
        create_time:'2025/05/05 11:11:11',
        status:'已结算',
        skfs:'二维码',
        money1:'+26',
        money2:'-2.90',
      },
      {
        id:'1023',
        merchant_name:'来自****吴',
        create_time:'2025/05/05 11:11:11',
        status:'已结算',
        skfs:'二维码',
        money1:'+26',
        money2:'-2.90',
      },
      {
        id:'1023',
        merchant_name:'来自****吴',
        create_time:'2025/05/05 11:11:11',
        status:'已结算',
        skfs:'二维码',
        money1:'+26',
        money2:'-2.90',
      },
      {
        id:'1023',
        merchant_name:'来自****吴',
        create_time:'2025/05/05 11:11:11',
        status:'已结算',
        skfs:'二维码',
        money1:'+26',
        money2:'-2.90',
      },
    ]
    pageData.page = 1;
    pageData.list_rows = 1;
    pageData.total = 4;
    table.loading = false;
  }

  onMounted(() => {
    getData();
  });

</script>
<style lang="scss" scoped>
  .success {
    color: #67C23A;
  }

  .fail {
    color: #FA5151;
  }

  .ing {
    color: #FFC300;
  }
  .el-tabs__active-bar{
    background-color: transparent !important;
  }
  .el-tabs__item.is-active{
    color: #000000 !important;
  }
  .el-tabs__item{
    color: #999999 !important;
  }
  .el-tabs__item:hover{
    color: #000000 !important;
  }
  .sa-title-top{
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    align-items: center;
    .title-text{
      font-size: 20px;
      font-family: Source Han Sans;
      font-weight: bold;
    }
    .title-btn{
      font-size: 12px;
      background-color: #515151;
      color: #FFFFFF;
      display: flex;
      height: 30px;
      padding: 0 5px;
      justify-content: center;
      align-items: center;
    }
  }
  .delete-btn{
    color: #FA5151;
  }
  .title-money{
    padding: 20px 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    background-color: #F5F5F5;
    .money-body{
        width: 14.2%;
        // display: flex;
        // justify-content: center;
        font-family: Source Han Sans;
        font-size: 14px;
        text-align: center;
        font-variation-settings: "opsz" auto;
        font-feature-settings: "kern" on;
        color: #373737;
        .money-text{
            text-align: center;
            width: 100%;
            span{
                font-size: 24px;
                font-weight: bold;
            }
        }
    }
  }
</style>